﻿using HealthcareSystem.API.Read.Application.Command.ChronicDisease;
using HealthcareSystem.Domain.ChronicDiseaseManagement;
using MediatR;
using WeekExam.PassPort.ErrorCode;
using WeekExam.PassPort.Infrastructure.Interface;

namespace HealthcareSystem.API.Read.Application.CommandHandel.ChronicDisease
{
    public class HealthMonitoringShowCommandHandler : IRequestHandler<HealthMonitoringShowCommand, ApiResult<List<HealthMonitoring>>>
    {
        private readonly IBaseRepository<HealthMonitoring> hmRepository;

        public HealthMonitoringShowCommandHandler(IBaseRepository<HealthMonitoring> hmRepository)
        {
            this.hmRepository = hmRepository;
        }

        public Task<ApiResult<List<HealthMonitoring>>> Handle(HealthMonitoringShowCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<HealthMonitoring>> result = new ApiResult<List<HealthMonitoring>>();
            result.Code = ResultCode.查询成功;
            result.Message = ResultCode.查询成功.ToString();
            result.Data = hmRepository.GetAll().ToList();
            return Task.FromResult(result);
        }
    }
}
